package com.t.bricks.bussiness.controller.stock;

import java.util.Date;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.t.bricks.bussiness.db.entity.stock.Stock;
import com.t.bricks.bussiness.service.stock.StockService;
import com.t.bricks.model.MsgEmity;

@RestController
@Api(value="库存表", tags={"仓储管理-库存表操作接口"})
@RequestMapping("/stock/")
public class StockController {

	/**
	 * 库存表业务实现类
	 */
	@Autowired
	private StockService stockService;

	//---------------------------- 自动生成代码结束 ----------------------------//

	/**
	 * 根据物品编号/仓库编号/批次取分组数据
	 * @param iWarehouse 启用仓库分组
	 * @param iBatch 启用批次分组
	 * @param sGoodsId 物品编号条件
	 * @param sWarehouseId 仓库编号条件
	 * @param sBatch 批次条件
	 * @param dMakeDateSt 生产日期范围-起
	 * @param dMakeDateEd 生产日期范围-止
	 * @return MsgEmity 返回查询结果
	 */
	//[start]
	@ApiOperation(value="根据物品编号/仓库编号/批次取分组数据", response=Stock.class)
	@ApiImplicitParams({
		@ApiImplicitParam(name="iWarehouse", value="启用仓库分组", dataType="Integer", paramType="query", required=false),
		@ApiImplicitParam(name="iBatch", value="启用批次分组", dataType="Integer", paramType="query", required=false),
		@ApiImplicitParam(name="sGoodsId", value="物品编号条件", dataType="String", paramType="query", required=false),
		@ApiImplicitParam(name="sWarehouseId", value="仓库编号条件", dataType="String", paramType="query", required=false),
		@ApiImplicitParam(name="sBatch", value="批次条件", dataType="String", paramType="query", required=false),
		@ApiImplicitParam(name="dMakeDateSt", value="生产日期范围-起", dataType="Date", paramType="query", required=false),
		@ApiImplicitParam(name="dMakeDateEd", value="生产日期范围-止", dataType="Date", paramType="query", required=false)
	})
	@ApiResponses({
		@ApiResponse(code=200, message="{\"success\": 布尔值, \"msg\": 文字提示, \"data\": 码值|Json数据对象集合}"),
		@ApiResponse(code=400, message="错误的请求,请检查路径"),
		@ApiResponse(code=404, message="请求路径没有或页面跳转路径不对"),
		@ApiResponse(code=1000001, message="内部请求密钥错误"),
		@ApiResponse(code=1000002, message="您还没有登录或登录已超时,需要重新登录"),
		@ApiResponse(code=1000003, message="检查登录状态失败,请稍后重试！"),
		@ApiResponse(code=1000004, message="请求的操作不存在,请检查访问地址正确性，如大小写"),
		@ApiResponse(code=1000005, message="响应后在系统内部发生不可预知的错误"),
		@ApiResponse(code=1019000, message="1019000~1999999为拦截器调用方法错误"),
		@ApiResponse(code=7001, message="查询数据发生异常，值为null"),
		@ApiResponse(code=7002, message="查询分页数据发生异常"),
		@ApiResponse(code=7003, message="7003~8998为查询时发生的其它错误")
	})
	//[end]
	@RequestMapping(method={RequestMethod.POST}, value="/find/group")
	public MsgEmity findByGroup(Integer iWarehouse, Integer iBatch,
			String sGoodsId, String sWarehouseId, String sBatch,
			Date dMakeDateSt, Date dMakeDateEd) {
		return stockService.findByGroup(iWarehouse, iBatch, sGoodsId,
				sWarehouseId, sBatch, dMakeDateSt, dMakeDateEd);
	}

	/**
	 * 检查当前库存量
	 * @param sGoodsId 物品编号条件
	 * @param sWarehouseId 仓库编号条件
	 * @param sBatch 批次条件
	 * @return MsgEmity 返回查询结果
	 */
	//[start]
	@ApiOperation(value="检查当前库存量")
	@ApiImplicitParams({
		@ApiImplicitParam(name="sGoodsId", value="物品编号条件", dataType="String", paramType="query", required=false),
		@ApiImplicitParam(name="sWarehouseId", value="仓库编号条件", dataType="String", paramType="query", required=false),
		@ApiImplicitParam(name="sBatch", value="批次条件", dataType="String", paramType="query", required=false)
	})
	@ApiResponses({
		@ApiResponse(code=200, message="{\"success\": 布尔值, \"msg\": 文字提示, \"data\": 码值|数量}"),
		@ApiResponse(code=400, message="错误的请求,请检查路径"),
		@ApiResponse(code=404, message="请求路径没有或页面跳转路径不对"),
		@ApiResponse(code=1000001, message="内部请求密钥错误"),
		@ApiResponse(code=1000002, message="您还没有登录或登录已超时,需要重新登录"),
		@ApiResponse(code=1000003, message="检查登录状态失败,请稍后重试！"),
		@ApiResponse(code=1000004, message="请求的操作不存在,请检查访问地址正确性，如大小写"),
		@ApiResponse(code=1000005, message="响应后在系统内部发生不可预知的错误"),
		@ApiResponse(code=1019000, message="1019000~1999999为拦截器调用方法错误"),
		@ApiResponse(code=7001, message="查询数据发生异常"),
		@ApiResponse(code=7002, message="7002~8998为查询时发生的其它错误")
	})
	//[end]
	@RequestMapping(method={RequestMethod.POST}, value="/find/quantity")
	public MsgEmity findQuantity(String sGoodsId, String sWarehouseId, String sBatch) {
		return stockService.findQuantity(sGoodsId, sWarehouseId, sBatch);
	}
	
}
